<template>
    <div class="edu-page-warp">
        <ConditionCard
            shadow="never"
            body-style="padding: 24px 24px 6px 24px;"
            @search="onSubmit"
            @reset="reset('queryForm')"
        >
            <el-form ref="queryForm" :model="queryForm" label-position="right" label-width="120px">
                <el-row :gutter="24" style="height: 50px;">
                    <el-col :span="8">
                        <el-form-item :label="$t('graduationList.graduationYear') + ':'" prop="graduationDate">
                            <el-date-picker
                                v-model="queryForm.graduationDate"
                                type="year"
                                style="width:100%"
                                value-format="yyyy"
                                @change="graduationDateChange"
                                :placeholder="$t('graduationList.pleaseSelect')">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('graduationList.auditBatch') + ':'" prop="reviewBatch">
                            <el-select v-model="queryForm.reviewBatch" filterable clearable style="width: 100%">
                                <el-option
                                    v-for="item in options.reviewBatch"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('label.college') + ':'" prop="faculty" >
                            <el-select
                                v-model="queryForm.faculty"
                                style="width: 100%;"
                                :filterable='role != 3'
                                :clearable='role !=3'
                                @change="getMajorOptions"
                            >
                                <el-option
                                    v-for="item in options.faculty"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item filterable :label="$t('graduationList.trainingProfessional') + ':'" prop="profession">
                            <el-select v-model="queryForm.profession" filterable clearable style="width: 100%">
                                <el-option
                                    v-for="item in options.profession"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <!-- <el-col :span="8">
                        <el-form-item filterable :label="$t('graduationList.nation') + ':'" prop="nation">
                            <el-select v-model="queryForm.nation" style="width: 100%">
                                <el-option
                                    v-for="item in options.nation"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col> -->
                    <el-col :span="8">
                        <el-form-item filterable :label="$t('graduationList.grade') + ':'" prop="currentGrade">
                            <el-date-picker
                                v-model="queryForm.currentGrade"
                                type="year"
                                style="width:100%"
                                value-format="yyyy"
                                @change="getMajorOptions()"
                                :placeholder="$t('graduationList.pleaseSelect')">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item filterable :label="$t('graduationList.sex') + ':'" prop="sex">
                            <el-select v-model="queryForm.sex" clearable style="width: 100%">
                                <el-option
                                    v-for="item in options.sex"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item filterable :label="$t('graduationList.schoolSystem') + ':'" prop="lengthSchooling">
                            <el-select v-model="queryForm.lengthSchoolingList"
                            clearable multiple collapse-tags
                            style="width: 100%"
                            >
                                <el-option
                                    v-for="item in options.lengthSchooling"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('graduationList.graduationStartTime') + ':'" prop="collegeReviewStartDate"
                        >
                            <el-date-picker
                                    style="width: 100%;"
                                    v-model="queryForm.collegeReviewStartDate"
                                    format="yyyy-MM-dd"
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    type="date"
                                    :placeholder="$t('graduationList.pleaseSelect')"
                                    clearable
                                ></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('graduationList.graduationEndTime') + ':'" prop="collegeReviewEndDate"
                        >
                            <el-date-picker
                                    style="width: 100%;"
                                    v-model="queryForm.collegeReviewEndDate"
                                    format="yyyy-MM-dd"
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    type="date"
                                    :placeholder="$t('graduationList.pleaseSelect')"
                                    clearable
                                ></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('graduationList.IDNumber') + ':'" prop="number" class="no-bottom">
                            <el-input
                                v-model="queryForm.number"
                                clearable
                               :placeholder="$t('graduationList.pleaseInput')"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('graduationList.certificateNo') + ':'" prop="certificateNo" class="no-bottom">
                            <el-input
                                v-model="queryForm.certificateNo"
                                clearable
                                :placeholder="$t('graduationList.pleaseInput')"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('graduationList.candidateNumber') + ':'" prop="examineeNo" class="no-bottom">
                            <el-input
                                v-model="queryForm.examineeNo"
                                clearable
                                :placeholder="$t('graduationList.pleaseInput')"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item filterable :label="$t('graduationList.collegeAuditConclusion') + ':'" prop="collegeAuditConclusion">
                            <el-select v-model="queryForm.collegeAuditConclusion" clearable style="width: 100%">
                                <el-option
                                    v-for="item in options.collegeAuditConclusion"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('culturePlan.degreeType') + ':'" prop="degreeType">
                            <el-select v-model="queryForm.degreeType" clearable style="width: 100%">
                                <el-option
                                    v-for="item in options.degreeType"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item filterable :label="$t('graduationList.submissionStatus') + ':'" prop="submit">
                            <el-select v-model="queryForm.submit" clearable style="width: 100%">
                                <el-option
                                    v-for="item in options.submit"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>

                </el-row>
            </el-form>
        </ConditionCard>
        <el-card shadow="never" body-style="padding: 24px;" class="card-margin">
            <div class="clearfix">
                <h1 class="condition-title float-left" style="width:150px;line-height: 30px; margin-bottom: 10px;">{{ $t('graduationList.ListOfGraduates') }}</h1>
                <div class="float-right btn-right-list" v-if="role == 4">
                    <el-row style="float:right; margin-bottom: 10px;">
                        <el-button type="danger"  @click="btn6">
                            {{ $t('graduationList.btn6') }}
                        </el-button>
                        <el-button type="primary"  @click="setNumeber('jiaowei')">
                            {{ $t('graduationList.btn3') }}
                        </el-button>
                        <el-button type="primary"  @click="exportFile('EXL')">
                            {{ $t('graduationList.btn4') }}
                        </el-button>
                        <el-button type="primary"  @click="exportFile('EKS')">
                            {{ $t('graduationList.importCandidateNumber') }}
                        </el-button>
                        <el-button type="primary"  @click="setNumeber('xuexin')">
                            {{ $t('graduationList.btn2') }}
                        </el-button>
                        <el-button type="primary"  @click="setNumeber('OA')">
                            {{ $t('graduationList.btnOA') }}
                        </el-button>
                        <el-button type="primary"  @click="setNumeber('report')">
                            {{ $t('graduationList.btnReport') }}
                        </el-button>
                    </el-row>
                </div>
            </div>
            <div class="div-main clearfix" :style="role ==4 && {'margin-bottom': '6px' }">
                <div style="width:190px" class="float-left">
                    <el-input
                        v-model="queryForm.name"
                        :placeholder="$t('graduationList.please')"
                        prefix-icon="el-icon-search"
                        @change="handleSearch"
                    />
                </div>
                <div style="float:right;" v-if="showMinorBtnInRole3">
                    <el-button type="primary"  @click="setNumeber('minor')">
                        {{ $t('graduationList.btn10') }}
                    </el-button>
                    <el-button type="primary"  @click="print('fuxiu')">
                        {{ $t('graduationList.btn9') }}
                    </el-button>
                </div>
                <div class="float-right btn-right-list" v-if="role == 4" style="width: calc(100% - 210px);">
                    <div style="float:right; margin-left: 10px; margin-bottom: 10px;">
                        <el-button type="primary"  @click="print('print')">
                            {{ $t('graduationList.btn12') }}
                        </el-button>
                        <el-button type="primary"  @click="setNumeber('degree')">
                            {{ $t('graduationList.btn11') }}
                        </el-button>
                        <el-button type="primary"  @click="exportTotalList">导出毕业的总名单</el-button>
                        <el-button type="primary"  @click="print('xuewei')">
                            {{ $t('graduationList.btn7') }}
                        </el-button>
                        <el-button type="primary"  @click="setNumeber('shangbao')">
                            {{ $t('graduationList.btn8') }}
                        </el-button>
                        <el-button type="primary"  @click="setNumeber('minor')">
                            {{ $t('graduationList.btn10') }}
                        </el-button>
                        <el-button type="primary"  @click="print('fuxiu')">
                            {{ $t('graduationList.btn9') }}
                        </el-button>
                    </div>
                    <div style="float: right;margin-bottom: 10px;">
                        <el-button type="primary" @click="handleStudent('addRecord')">
                            {{$t('common.btn.add')}}
                        </el-button>
                    </div>
                </div>
            </div>
            <EduTable
                :data="tableData"
                @page-change="handleCurrentChange"
                :total="queryForm.total"
                :pageSize="queryForm.pageSize_"
                :page-num="queryForm.pageNum_"
                :orderFixed='true'
                 @selection-change="handleSelectionChange"
                :cellClassName="cellClass"
                class="collage-content"
            >
                <el-table-column :label="$t('graduationList.studentID')" prop="studentId" min-width="70" fixed></el-table-column>
                <el-table-column :label="$t('graduationList.name')" prop="name" fixed min-width="70"></el-table-column>
                <el-table-column :label="$t('graduationList.nameEn')" prop="nameSpelling" min-width="80" show-overflow-tooltip fixed></el-table-column>
                <el-table-column :label="$t('label.college')" prop="facultyI18n" min-width="100" show-overflow-tooltip fixed></el-table-column>
                <el-table-column :label="$t('graduationList.trainingProfessional')" prop="professionI18n" width="130" show-overflow-tooltip></el-table-column>
                <el-table-column :label="$t('graduationList.statusProfession')" prop="statusProfessionName" min-width="95" show-overflow-tooltip></el-table-column>
                <el-table-column :label="$t('graduationList.collegeAuditConclusion')" width="95" show-overflow-tooltip>
                    <template slot-scope="scope">
                        <span v-if="scope.row.collegeAuditConclusion == 1"  size="mini">{{ $t("graduationList.graduation") }}</span>
                        <span v-if="scope.row.collegeAuditConclusion == 2"  size="mini">{{ $t("graduationList.NotGraduation") }}</span>
                        <span v-if="scope.row.collegeAuditConclusion == 3"  size="mini">{{ $t("graduationList.undergraduate") }}</span>
                    </template>
                </el-table-column>
                <el-table-column :label="$t('graduationList.bachelorScience')" prop="degreeI18n" width='110' show-overflow-tooltip></el-table-column>
                <el-table-column :label="$t('culturePlan.degreeType')" prop="degreeTypeI18n" show-overflow-tooltip></el-table-column>
                <el-table-column :label="$t('graduationList.certificateNo')" prop="certificateNo" width="155" show-overflow-tooltip></el-table-column>
                <el-table-column :label="$t('graduationList.degreeCertificateNumber')" prop="diplomaNo" width="140" show-overflow-tooltip></el-table-column>
                <el-table-column :label="$t('graduationList.nation')" prop="nationI18n"></el-table-column>
                <el-table-column :label="$t('graduationList.IDNumber')" prop="number" width="165" show-overflow-tooltip></el-table-column>
                <el-table-column :label="$t('graduationList.sex')" prop="sexI18n"></el-table-column>
                <el-table-column :label="$t('graduationList.traininglevel')" prop="trainingLevelI18n"></el-table-column>
                <el-table-column :label="$t('graduationList.enrollmentDate')" prop="enrolDate" width="120"></el-table-column>
                <el-table-column :label="$t('graduationList.graduationSeason')" prop="graduationSeasonI18n"></el-table-column>
                <el-table-column :label="$t('graduationList.graduationYear')" prop="graduationDate"></el-table-column>
                <el-table-column :label="$t('graduationList.principal')" prop="principalName"></el-table-column>
                <el-table-column :label="$t('graduationList.grade')" prop="grade"></el-table-column>
                <el-table-column :label="$t('graduationList.birthday')" prop="birthdayStr" width="120"></el-table-column>
                <el-table-column :label="$t('graduationList.schoolSystem')" prop="lengthSchooling"></el-table-column>
                <el-table-column :label="$t('graduationList.failingCourse')" prop="noPassCourse" width="280" show-overflow-tooltip></el-table-column>
                <!-- <el-table-column :label="$t('graduationList.certificateNo')" prop="certificateNo" width="170" show-overflow-tooltip></el-table-column> -->
                <el-table-column :label="$t('graduationList.minorProfessionalCertificate')" prop="minorCertificateNo" width="170" show-overflow-tooltip></el-table-column>
                <!-- <el-table-column :label="$t('graduationList.degreeCertificateNumber')" prop="diplomaNo" width="170" show-overflow-tooltip></el-table-column>             -->
                <el-table-column :label="$t('graduationList.candidateNumber')" prop="examineeNo" width="170"  show-overflow-tooltip></el-table-column>
                <el-table-column :label="$t('graduationList.AdmissionTicketNumber')" prop="preTestCode" width="120" show-overflow-tooltip></el-table-column>
                <el-table-column :label="$t('graduationList.formerName')" prop="usedName" show-overflow-tooltip></el-table-column>
                <el-table-column :label="$t('graduationList.remark')" prop="manualRemark" show-overflow-tooltip></el-table-column>
                <!-- <el-table-column :label="$t('graduationList.collegeAuditConclusion')" width="120" show-overflow-tooltip>
                    <template slot-scope="scope">
                        <span v-if="scope.row.collegeAuditConclusion == 1"  size="mini">{{ $t("graduationList.graduation") }}</span>
                        <span v-if="scope.row.collegeAuditConclusion == 2"  size="mini">{{ $t("graduationList.NotGraduation") }}</span>
                        <span v-if="scope.row.collegeAuditConclusion == 3"  size="mini">{{ $t("graduationList.undergraduate") }}</span>
                    </template>
                </el-table-column> -->
                <el-table-column :label="$t('graduationList.graduationTime')" prop="graduateTime" width="120"></el-table-column>
                <el-table-column :label="$t('graduationList.degreeTime')" prop="toDegreeTime" width="120"></el-table-column>
                <el-table-column :label="$t('graduationList.auditBatch')" show-overflow-tooltip fixed="right" width="65">
                    <template slot-scope="scope">
                        <span v-if="scope.row.reviewBatchI18n"  size="mini">{{ scope.row.reviewBatchI18n }}</span>
                        <span v-else  size="mini">{{ $t("graduationList.noPending") }}</span>
                    </template>
                </el-table-column>
                <el-table-column :label="$t('graduationList.submissionStatus')" fixed="right" width="65">
                    <template slot-scope="scope">
                        <el-tag v-if="scope.row.submit == 1" type="success" size="mini">{{ $t("graduationList.submitted") }}</el-tag>
                        <el-tag v-if="scope.row.submit == 2" type="warning" size="mini">{{ $t("graduationList.returned") }}</el-tag>
                        <!-- <el-tag v-if="scope.row.submit == 3" type="info" size="mini">{{ $t("graduationList.submitted") }}</el-tag> -->
                        <el-tag v-if="scope.row.submit == 0 || scope.row.submit == 3" type="danger" size="mini">{{ $t("graduationList.unsubmitted") }}</el-tag>
                    </template>
                </el-table-column>
                <edu-table-column :label="$t('common.text.operation')" v-if="role == 4"  width="80" fixed="right">
                    <template slot-scope="scope">
                        <el-button type="text" size="mini" @click.stop="handleStudent('editRecord', scope.row)">{{$t('common.btn.edit')}}</el-button>
                        <el-button type="text" size="mini" @click.stop="handleStudent('deleteRecord', scope.row)">{{$t('common.btn.delete')}}</el-button>
                    </template>
                </edu-table-column>
            </EduTable>
        </el-card>
        <div v-if="studentDialog.add.show">
            <add-student :show.sync='studentDialog.add.show' :sendData='studentDialog.sendData'></add-student>
        </div>
        <div v-if="studentDialog.edit.show">
            <edit-student :show.sync='studentDialog.edit.show' :sendData='studentDialog.sendData'></edit-student>
        </div>
        <el-dialog
            title="确认退回审核结论"
            :visible.sync="btn6Dialog"
            width="40%"
            @close="resetbtn6()"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
        >
            <EduTable
                :data="tableBtn6Data"
                @selection-change="btn6SelectionChange"
                :pagination="false"
                ref="btn6table"
            >
                <el-table-column :label="$t('graduationList.studentID')" prop="studentId"></el-table-column>
                <el-table-column :label="$t('graduationList.name')" prop="name"></el-table-column>
                <el-table-column :label="$t('graduationList.auditConclusion')">
                    <template slot-scope="scope">
                        <span v-if="scope.row.collegeAuditConclusion == 1"  size="mini">{{ $t("graduationList.graduation") }}</span>
                        <span v-if="scope.row.collegeAuditConclusion == 2"  size="mini">{{ $t("graduationList.NotGraduation") }}</span>
                        <span v-if="scope.row.collegeAuditConclusion == 3"  size="mini">{{ $t("graduationList.undergraduate") }}</span>
                    </template>
                </el-table-column>
            </EduTable>
            <el-row>
                <el-col :span="24">
                    <div class="float-right" style="margin-top:30px">
                        <el-button @click="cancelbtn6Dialog">{{ $t('common.btn.cancel') }}</el-button>
                        <el-button
                            type="primary"
                            @click="confirmbtn6Dialog"
                        >{{ $t('common.btn.confirm') }}</el-button>
                    </div>
                </el-col>
            </el-row>
        </el-dialog>
        <el-dialog
            :title="title"
            :visible.sync="showCourseDialog"
            width="40%"
            @close="resetFormValidate()"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
        >
            <el-form
                ref="mechineForm"
                :model="mechineForm"
                :rules="mechineRules"
                label-width="125px"
                label-position="right"
                size="mini"
                class="bg-white"
            >
                <el-row>
                    <el-col :span="16" :offset='1'>
                        <el-form-item :label="$t('graduationList.graduationYear') + ':'" prop="graduationDate">
                            <el-date-picker
                                v-model="mechineForm.graduationDate"
                                type="year"
                                style="width:100%"
                                value-format="yyyy"
                                @change="getReviewBatch2"
                                :placeholder="$t('graduationList.pleaseSelect')">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row v-if="$t('graduationList.resetGraduationList') != title">
                    <el-col :span="16" :offset='1'>
                            <el-form-item :label="$t('graduationList.auditBatch') + ':'" prop="reviewBatch">
                                <el-select v-model="mechineForm.reviewBatch" style="width: 100%">
                                    <el-option
                                        v-for="item in mechineOptions.reviewBatch"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    />
                                </el-select>
                            </el-form-item>
                    </el-col>
                </el-row>
                <el-row v-if="$t('graduationList.btn2') == title || $t('graduationList.btn3') == title">
                    <el-col :span="16" :offset='1'>
                            <el-form-item :label="$t('graduationList.auditConclusion') + ':'" prop="collegeAuditConclusion">
                                <el-select v-model="collegeAuditConclusion" style="width: 100%">
                                    <el-option
                                        key="0"
                                        label="全部"
                                        value="0"
                                    />
                                    <el-option
                                        key="5"
                                        label="毕结业"
                                        value="5"
                                    />
                                    <el-option
                                        v-for="item in options.collegeAuditConclusion"
                                        :key="item.value"
                                        v-if="item.label === $t('graduationList.undergraduate')"
                                        :label="item.label"
                                        :value="item.value"
                                    />
                                    <el-option
                                        v-if="$t('graduationList.btn2') == title"
                                        key="4"
                                        label="修改预计毕业日期"
                                        value="4"
                                    />
                                </el-select>
                            </el-form-item>
                    </el-col>
                </el-row>
                <el-row v-if="$t('graduationList.btn8') == title">
                    <el-col :span="16" :offset='1'>
                            <el-form-item :label="$t('culturePlan.degreeType') + ':'" prop="degreeType">
                                <el-select v-model="mechineForm.degreeType" style="width: 100%">
                                    <el-option
                                        v-for="item in options.degreeType"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                        v-if='item.value != 3'
                                    />
                                </el-select>
                            </el-form-item>
                    </el-col>
                </el-row>
                <el-row v-if="mode === 'xuexin'">
                    <el-col :span="16" :offset='1'>
                        <el-form-item :label="$t('graduationList.exportFormat') + ':'">
                            <el-radio-group v-model="exportFileType">
                                <el-radio label="1">EXCEL文件</el-radio>
                                <el-radio label="2">DBF文件</el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <el-row>
                <el-col :span="24">
                    <div class="float-right">
                        <el-button @click="cancelDialog">{{ $t('common.btn.cancel') }}</el-button>
                        <el-button
                            type="primary"
                            @click="confirmDialog"
                        >{{ $t('common.btn.confirm') }}</el-button>
                    </div>
                </el-col>
            </el-row>
        </el-dialog>
        <el-dialog
            :title="title"
            :visible.sync="showPrintDialog"
            width="40%"
            @close="resetPrintValidate()"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
        >
            <el-form
                ref="printForm"
                :model="printForm"
                :rules="printRules"
                label-width="125px"
                label-position="right"
                size="mini"
                class="bg-white"
            >
                <el-row v-if="$t('graduationList.btn12') == title">
                    <el-col :span="16" :offset='1'>
                        <el-form-item label="打印类型:" prop="printType">
                            <el-select v-model="printForm.printType" @change="checkType" style="width: 100%">
                                <el-option
                                    v-for="item in mechineOptions.exportType"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row v-if="printForm.printType == 3 || printForm.printType == 5">
                  <el-col :span="16" :offset='1'>
                    <el-form-item label="文件类型:" prop="fileType">
                      <el-select v-model="printForm.fileType" style="width: 100%">
                        <el-option
                          v-for="item in mechineOptions.fileTypes"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        />
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row v-if="$t('graduationList.btn9') == title">
                    <el-col :span="16" :offset='1'>
                        <el-form-item label="文件类型:" prop="fileType">
                            <el-select v-model="printForm.fileType" @change="checkWordType" style="width: 100%">
                                <template v-for="item in mechineOptions.fileType">
                                     <el-option
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                        v-if="!(role == 3 && item.value != 1)"
                                    />
                                </template>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="16" :offset='1' v-if="printForm.printType || printForm.fileType || $t('graduationList.btn7') == title || $t('graduationList.btn9') == title">
                        <el-form-item :label="$t('graduationList.graduationYear') + ':'" prop="graduationDate">
                            <el-date-picker
                                v-model="printForm.graduationDate"
                                type="year"
                                style="width:100%"
                                value-format="yyyy"
                                @change="printFormGraduationDateChange"
                                :placeholder="$t('graduationList.pleaseSelect')">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="16" :offset='1' v-if="(printForm.printType && printForm.printType != 4 && printForm.printType !=5) || $t('graduationList.btn7') == title">
                        <el-form-item :label="$t('label.college') + ':'" prop="faculty" >
                            <el-select
                                v-model="printForm.faculty"
                                style="width: 100%;"
                                clearable
                                filterable
                                :disabled="flag"
                                @change="getMajorOptions2"
                            >
                                <el-option
                                    v-if="$t('graduationList.btn7') == title"
                                    key="0"
                                    label="全部"
                                    value="0"
                                />
                                <el-option
                                    v-for="item in mechineOptions.faculty"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                     <el-col :span="16" :offset='1' v-if="(printForm.printType && printForm.printType != 4 && printForm.printType !=5) || $t('graduationList.btn7') == title">
                        <el-form-item filterable :label="printForm.printType == 2 && $t('graduationList.trainingProfessional') || $t('graduationList.statusProfession') + ':'"  prop="profession"  :rules="printForm.printType != 0 && printForm.printType !=1 && [
                    {
                        required: true,
                        message: '请选择专业',
                        trigger: 'change'
                    }] || ''">
                        <el-select v-model="printForm.profession" @change="getShoolLength" style="width: 100%">
                            <el-option
                                v-if="$t('graduationList.btn7') == title"
                                key="0"
                                label="全部"
                                value="0"
                            />
                            <template v-if="printForm.printType || $t('graduationList.btn7') == title">
                                    <el-option
                                    v-for="item in ministryEduOption"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </template>
                            <template v-else>
                                    <el-option
                                    v-for="item in mechineOptions.profession"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </template>
                        </el-select>
                    </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="16" :offset='1' v-if=" (printForm.printType && printForm.printType == 0) || printForm.printType ==3 || printForm.printType ==1 || printForm.printType ==2">
                        <el-form-item filterable :label="$t('graduationList.schoolSystem') + ':'" prop="lengthSchooling">
                            <el-select v-model="printForm.lengthSchooling" style="width: 100%">
                                <el-option
                                    v-for="item in mechineOptions.lengthSchooling"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="16" :offset='1' v-if="(printForm.printType && printForm.printType != 4 && printForm.printType !=5) || $t('graduationList.btn7') == title || $t('graduationList.btn9') == title">
                        <el-form-item :label="$t('graduationList.auditBatch') + ':'" prop="reviewBatch">
                            <el-select v-model="printForm.reviewBatch" style="width: 100%">
                                <el-option
                                    v-for="item in mechineOptions.reviewBatch"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row v-if="$t('graduationList.btn7') == title || printForm.fileType ==3">
                    <el-col :span="16" :offset='1'>
                            <el-form-item :label="$t('culturePlan.degreeType') + ':'" prop="degreeType">
                                <el-select v-model="printForm.degreeType" style="width: 100%">
                                    <el-option
                                        v-for="item in options.degreeType"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                        v-if='item.value != 3'
                                    />
                                </el-select>
                            </el-form-item>
                    </el-col>
                </el-row>
                <el-row v-if="mode=== 'fuxiu' && printForm.fileType == 2">
                    <el-col :span="16" :offset='1'>
                        <el-form-item :label="$t('graduationList.exportFormat') + ':'">
                            <el-radio-group v-model="exportFileType">
                                <el-radio label="1">EXCEL文件</el-radio>
                                <el-radio label="2">DBF文件</el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <el-row>
                <el-col :span="24">
                    <div class="float-right">
                        <el-button @click="printCancelDialog">{{ $t('common.btn.cancel') }}</el-button>
                        <el-button
                            type="primary"
                            @click="printConfirmDialog"
                        >{{ $t('common.btn.confirm') }}</el-button>
                    </div>
                </el-col>
            </el-row>
        </el-dialog>
        <!--导入弹框-->
        <edu-dialog ref="uploadDialog"
                    :title='uploadDialogTitle'
                    :confirmBtnText="$t('common.btn.confirm')"
                    size="small"
                    @close="clearFiles"
                    @confirm="uploadFile">
            <el-form v-loading="loading2"
                    ref="createStudentForm"
                    :model="createStudentForm"
                    label-width="85px">
                <el-row>
                    <el-form-item>
                    <el-upload ref="upload"
                                :data="{}"
                                :on-success="uploadDone"
                                :auto-upload="false"
                                :multiple="false"
                                :on-change="(file, fileList)=>{ this.fileList = fileList}"
                                :limit="1"
                                :accept="'.xlsx'"
                                :action="importUrl">
                        <el-button slot="trigger"
                                size="small"
                                type="primary">{{ $t('label.selectFile') }}
                        </el-button>
                        <el-button size="small" @click="downloadFile">{{ $t('graduationList.templateDownload') }}</el-button>
                        <div slot="tip"
                            class="el-upload__tip">{{ $t('courseTake.uploadXLSFileOnly') }}
                        </div>
                    </el-upload>
                    </el-form-item>
                </el-row>
            </el-form>
        </edu-dialog>
    </div>
</template>
<script>
import bus from "common/src/utils/bus";
import UTILS from "common/src/utils/utils";
import down from "common/src/utils/file";
import { queryDic, findTrainingLevelByProjId } from "common/src/api/dictionary";
// import { findFaculty } from "common/src/api/faculty";
import {findBelongBigProfessionByFaculty} from 'common/src/api/culture/bachelor'
import {
    findAllGraduateReviewBatch,
    findGraduateList,editCertificateNo,
    editMinorCertificateNo,
    saveReturnReviewConclusion,
    createGraduateList,
    printPdfInList,
    findFaculty
} from 'common/src/api/graduationManagement/graduationList'
import {forMateTimeToStr} from '../../components/gradMangeUtis';
import { getPower } from "common/src/api/culture/culturePlan";
import manageApi from 'common/src/api/graduationManagement/graduationManage';
export default {
    name: "graduationList",
    components: {
        addStudent: resolve => require(['../../components/addStudent'], resolve),
        editStudent: resolve => require(['../../components/editStudent'], resolve)
    },
    data() {
        return {
            // 筛选相关选项
            queryForm: {
                isOverseas: "1",
                grade: "", // 年级
                graduationDate: "",
                reviewBatch: "",
                faculty: "",
                profession: "",
                //nation: "",
                currentGrade: "",
                sex: "",
                lengthSchoolingList: [],
                collegeReviewStartDate: "",
                collegeReviewEndDate: "",
                number: "",
                certificateNo:"",
                examineeNo:"",
                collegeAuditConclusion:"",
                submit:"",
                degreeType: "",
                pageNum_: 1,
                pageSize_: 20,
                name:"",
                total: 0
            },

            // 下拉相关选项数据
            options: {
                graduationDate:[],
                reviewBatch: [],
                trainingLevel: [],
                professionCateGory: [],
                faculty: [],
                profession: [],
                //nation: [],
                sex: [],
                lengthSchooling: [
                    {
                        value: "0.5",
                        label: "0.5"
                    },
                    {
                        value: "1",
                        label: "1"
                    },
                    {
                        value: "1.5",
                        label: "1.5"
                    },
                    {
                        value: "2",
                        label: "2"
                    },
                    {
                        value: "2.5",
                        label: "2.5"
                    },
                    {
                        value: "3",
                        label: "3"
                    },
                    {
                        value: "3.5",
                        label: "3.5"
                    },
                    {
                        value: "4",
                        label: "4"
                    },
                    {
                        value: "4.5",
                        label: "4.5"
                    },
                    {
                        value: "5",
                        label: "5"
                    },
                    {
                        value: "5.5",
                        label: "5.5"
                    },
                    {
                        value: "6",
                        label: "6"
                    },
                    {
                        value: "7",
                        label: "7"
                    },
                    {
                        value: "8",
                        label: "8"
                    }
                ],
                collegeAuditConclusion: [],
                submit: [
                    {
                        value: "0",
                        label: this.$t("graduationList.unsubmitted")
                    },
                    {
                        value: "1",
                        label: this.$t("graduationList.submitted")
                    },
                    {
                        value: "2",
                        label: this.$t("graduationList.returned")
                    }
                ],
                degreeType: []
            },
            mechineRules: {
                graduationDate: [
                    {
                        required: true,
                        message: "请选择毕业年份",
                        trigger: "change"
                    }
                ],
                reviewBatch: [
                    {
                        required: true,
                        message: "请选择审核批次",
                        trigger: "change"
                    }
                ],
                degreeType: [
                    {
                        required: true,
                        message: "请选择学位类型",
                        trigger: "change"
                    }
                ],
            },
            printRules: {
                printType: [
                    {
                        required: true,
                        message: "请选择打印类型",
                        trigger: "change"
                    }
                ],
                fileType: [
                    {
                        required: true,
                        message: "请选择文件类型",
                        trigger: "change"
                    }
                ],
                graduationDate: [
                    {
                        required: true,
                        message: "请选择毕业年份",
                        trigger: "change"
                    }
                ],
                degreeType: [
                    {
                        required: true,
                        message: "请选择学位类型",
                        trigger: "change"
                    }
                ],
                faculty: [
                    {
                        required: true,
                        message: "请选择学院",
                        trigger: "change"
                    }
                ],
                // profession: [
                //     {
                //         required: true,
                //         message: "请选择专业",
                //         trigger: "change"
                //     }
                // ],
            },
            mechineForm: {
                isOverseas: "1",
                graduationDate: "",
                reviewBatch: "",
                degreeType:"",
            },
            printForm: {
                isOverseas: "1",
                printType:"",
                graduationDate: "",
                reviewBatch: "",
                faculty:"",
                profession:"",
                lengthSchooling:"",
                degreeType:'',
                fileType:''
            },

            collegeAuditConclusion:"0",
            mechineOptions: {
                reviewBatch: [],
                faculty: [],
                profession: [],
                lengthSchooling: [],
                exportType:[
                    {
                        value: "0",
                        label: "毕业生预计名单"
                    },
                    {
                        value: "1",
                        label: "证书发放审批表"
                    },
                    {
                        value: "2",
                        label: "辅修证书发放审批表"
                    },
                    {
                        value: "3",
                        label: "证书发放名单"
                    },
                    {
                        value: "4",
                        label: "毕业生预计名单院系统计"
                    },
                    {
                        value: "5",
                        label: "毕业生预计名单全校统计"
                    }
                ],
                fileType:[
                    {
                        value: "1",
                        label: "辅修专业证书"
                    },
                    {
                        value: "2",
                        label: "辅修专业（学信网）"
                    },
                    {
                        value: "3",
                        label: "辅修专业（学位网）"
                    },
                ],
                fileTypes:[
                    {
                        value: "1",
                        label: "PDF"
                    },
                    {
                        value: "2",
                        label: "EXCEL"
                    }
                ],
            },
            multipleSelection:[],
            title:'',
            tableData: [],
            role:'',
            showCourseDialog:false,
            showPrintDialog:false,
            btn6Dialog:false,
            flag:false,
            tableBtn6Data:[],
            btn6Selection:[],
            importUrl:'',
            uploadDialogTitle: '',
            mode: '',
            studentDialog: {
                add: {
                    show:  false
                },
                edit: {
                    show: false
                },
                sendData: {
                    title: ''
                }
            },
            exportFileType: '',
            ministryEduOption: [],
            showMinorBtnInRole3: false
        };
    },

    created() {
        //this.init();
        this.getRole();
    },
    mounted() {

    },
    methods: {
        init() {
            //绑定年级
            let now = new Date();
            let currentYear = now.getFullYear()
            this.queryForm.graduationDate = `${currentYear}`;
            this.getReviewBatch();
            //     minYear = currentYear - 16;
            // for (let grade = currentYear; grade > minYear; grade--) {
            //     let obj = { label: grade, value: grade };
            //     this.options.graduationDate.push(obj);
            // }
            // this.queryForm["x-token"] =
            //     this.$store.state.session.sessionid ||
            //     localStorage.getItem("sessionid") ||
            //     "";
            this.initOptions();
        },
        initOptions() {
            this.getFacultyList('init');
            // findFaculty().then(res => {
            //     let data = {"X_YX": res.data};
            //     UTILS.fillSelect({ faculty: "X_YX" }, data, this.options);
            //     if(this.role == 3){
            //         this.queryForm.faculty = this.options.faculty[0].value
            //         this.handleSearch();
            //         this.getMajorOptions()
            //     }
            // });
            const data = {
                lang: this.$store.getters.language || "cn",
                type: "allChild",
                keys: ["G_XBIE", "X_PYLB", "G_MZ", "X_XWLX", "X_BYJL"]
            };
            queryDic(data).then(res => {
                if (res.code == 200) {
                    UTILS.fillSelect(
                        {
                            sex: "G_XBIE",
                            nation: "G_MZ",
                            trainingCategory: "X_PYLB",
                            collegeAuditConclusion: "X_BYJL",
                            degreeType: "X_XWLX"
                        },
                        res.data,
                        this.options
                    );
                    this.options.nation = _.sortBy(this.options.nation, ["value"]);
                }
            });
        },
        graduationDateChange() {
          this.getFacultyList();
          this.getReviewBatch();
        },
        getFacultyList(type) {
            let param = {
                graduationDate: this.queryForm.graduationDate || '',
                isOverseas: this.queryForm.isOverseas
            };
            this.queryForm.faculty = '';
            this.getFaculty(this.options, param, type);
        },
        printFormGraduationDateChange() {
            this.getDialogFaculty();
            this.getReviewBatch2();
        },
        getDialogFaculty(){
            let param = {
                graduationDate: this.printForm.graduationDate || '',
                isOverseas: this.queryForm.isOverseas
            };
            this.printForm.faculty = '';
            this.getFaculty(this.mechineOptions, param, 'dialog');
        },
        getFaculty(options, param, type) {
            options = options || {};
            options.faculty = [];
            findFaculty(param).then(res => {
                let data = {
                    "X_YX": res.data
                };
                UTILS.fillSelect({
                    faculty: "X_YX"
                }, data, options);
                if (this.role == 3 && type == "init") {
                    this.queryForm.faculty = this.options.faculty[0] && this.options.faculty[0].value;
                    this.handleSearch();
                    this.getMajorOptions()
                }
                if (this.printForm.printType == 2 && type == 'dialog'){
                    let spec = options.faculty.find(item => {
                            return item.value == '000182'
                        })
                    if (spec) {
                        this.printForm.faculty = spec.value
                    }
                    this.getMajorOptions2()
                }
            });
        },
        getReviewBatch(){
            this.options.reviewBatch = [];
            this.queryForm.reviewBatch = "";
            if (!this.queryForm.graduationDate) {
                return;
            }
            findAllGraduateReviewBatch({
                isOverseas: '1',
                graduateData: this.queryForm.graduationDate
            })
            .then(res => {
                if (res.code == 200) {
                    this.options.reviewBatch = res.data.list.map((item, index) => {
                        return {
                            label: item.reviewBatchI18n,
                            value: item.reviewBatch
                        }
                    })
                    this.options.reviewBatch.push({
                        value: "0",
                        label: "未审核"
                    },
                    {
                        value: "",
                        label: "全部"
                    },)
                }
            });
        },
        getReviewBatch2(){
            if(this.$t('graduationList.resetGraduationList') != this.title){
                this.mechineOptions.reviewBatch = [];
                this.mechineForm.reviewBatch = "";
                this.printForm.reviewBatch = "";
                findAllGraduateReviewBatch({
                    isOverseas: '1',
                    graduateData: this.mechineForm.graduationDate || this.printForm.graduationDate
                })
                .then(res => {
                    if (res.code == 200) {
                        let batchs = [];
                        let allBatch = [{
                                value: "6",
                                label: "全部"
                            }
                        ];
                        let noBatch = [{
                            value: "0",
                            label: "未审核"
                        }]
                        batchs = res.data.list.map((item, index) => {
                            return {
                                label: item.reviewBatchI18n,
                                value: item.reviewBatch
                            }
                        })
                        let deleteNotAudit = ['fuxiu', 'degree', 'minor', 'report', 'OA'];
                        if (deleteNotAudit.indexOf(this.mode) > -1) {
                            noBatch = [];
                        }
                        if (this.mode == 'OA' || this.mode == 'report') {
                            allBatch = [];
                        }
                        this.mechineOptions.reviewBatch = [
                            ...allBatch,
                            ...noBatch,
                            ...batchs
                        ]
                        if(this.printForm.printType && this.printForm.faculty){
                            this.getMajorOptions2()
                            //this.getShoolLength()
                        }
                        // if(this.title == this.$t("graduationList.btn7")){
                        //     this.printForm.reviewBatch = '6'
                        // }
                    }
                });
            }
        },
        getRole() {
            getPower().then(res => {
                this.role = res.data.power;
                let departmentCode = res.data && res.data.departmentCode || '';
                let codeExist = false, code= '000182';
                if (departmentCode.indexOf(",") !=-1){
                    const departmentCodeArr = res.data.departmentCode.split(",");
                    codeExist = departmentCodeArr.find(item => code == item);
                }else{
                    codeExist = departmentCode == code;
                }
                if(this.role == 4){
                    this.handleSearch();
                }
                if (this.role == 3 && codeExist) {
                    this.showMinorBtnInRole3 = true;
                }
                this.init();
            });
        },
        getShoolLength() {
            this.mechineOptions.lengthSchooling = [];
            this.printForm.lengthSchooling = "";
            if (!this.printForm.profession) return;
            let  schoolSystem = this.lengthSchoolingMaps[this.printForm.profession];
            if (schoolSystem != '') {
                this.mechineOptions.lengthSchooling = [{
                    label: schoolSystem,
                    value: schoolSystem
                }]
                this.printForm.lengthSchooling = schoolSystem;
            }
            // if(this.printForm.faculty && this.printForm.profession && this.printForm.graduationDate){
            //     manageApi.getProfessionByGrade({
            //         faculty: this.printForm.faculty,
            //         profession: this.printForm.profession,
            //         graduateDate: this.printForm.graduationDate,
            //     })
            //     .then(res => {
            //         if (res.code == 200) {
            //             let data = res.data || [];
            //             if(data.length > 0){
            //                 let  lengthSchooling = data.filter(d => d.professionCateGory == this.printForm.profession)
            //                 this.mechineOptions.lengthSchooling = lengthSchooling.map((item, index) => {
            //                     return {
            //                         label: item.lengthSchooling,
            //                         value: item.lengthSchooling
            //                     }
            //                 })
            //                 this.printForm.lengthSchooling = this.mechineOptions.lengthSchooling[0].value;
            //             }
            //         }
            //     });
            // }
        },
        handleSearch() {
            findGraduateList(this.queryForm).then(res => {
                if (res.code == 200) {
                    if(res.data.list.length > 0){
                        res.data.list.forEach(item =>{
                            if (item.enrolDate){
                                item.enrolDate = item.enrolDate.split(" ")[0];
                            }
                            if (item.graduateTime) {
                                item.graduateTime = item.graduateTime.split(" ")[0];
                            }
                            if (item.toDegreeTime) {
                                item.toDegreeTime = item.toDegreeTime.split(" ")[0];
                           }
                           item.professionI18n = item.professionName || item.professionI18n;
                           if (item.directionName) {
                                item.professionI18n &&  (item.professionI18n =  item.professionI18n + ` [${item.directionName}]`);
                            }
                        })
                    }
                    this.tableData = res.data.list;
                    this.queryForm.pageNum_ = res.data.pageNum_;
                    this.queryForm.pageSize_ = res.data.pageSize_;
                    this.queryForm.total = res.data.total_;
                    // if(this.queryForm.lengthSchooling.length > 0){
                    //     this.queryForm.lengthSchooling = this.queryForm.lengthSchooling.split(',')
                    // }else{
                    //     this.queryForm.lengthSchooling = []
                    // }
                }
            });
        },
        handleCurrentChange(val) {
            this.queryForm.pageNum_ = val.pageNum;
            this.queryForm.pageSize_ = val.pageSize;
            this.handleSearch();
        },
        handleSelectionChange(selection) {
            this.multipleSelection = selection;
        },
        getMajorOptions() {
            this.options.profession = [];
            this.queryForm.profession = "";
            if (!this.queryForm.faculty) {
                return;
            }
            findBelongBigProfessionByFaculty({
                faculty: this.queryForm.faculty,
                grade: this.queryForm.currentGrade && Number(this.queryForm.currentGrade),
                projId: '1',
                pageNum_: 1,
                pageSize_: 100
            })
            .then(res => {
                if (res.code == 200) {
                    let profession = res.data.list.map((item, index) => {
                        return {
                            label: item.professionName + '-' + item.professionCode,
                            value: item.professionCode
                        }
                    })
                    this.options.profession = _.uniqBy(profession, 'value');
                }
            });
        },
        getMajorOptions2() {
            this.mechineOptions.profession = [];
            this.ministryEduOption = [];
            this.printForm.profession = "";
            this.lengthSchoolingMaps = {};
            this.getShoolLength();
            if (!this.printForm.graduationDate) {
                return;
            }
            let promiseFn;
            //辅修证书发放审批表单独处理
            if (this.printForm.printType == 2) {
                promiseFn = manageApi.getProfessionByGrade({
                    faculty: this.printForm.faculty,
                    graduateDate: this.printForm.graduationDate,
                })
            }else {
                promiseFn =  manageApi.findStaProfessionList({
                    faculty: this.printForm.faculty,
                    graduationDate: this.printForm.graduationDate,
                    isOverseas: this.queryForm.isOverseas
                })
            }
            promiseFn.then(res => {
                if (res.code == 200) {
                    let data = res.data || [];
                    let ministryEduOption = [];
                    this.mechineOptions.profession = data.map((item, index) => {
                        this.lengthSchoolingMaps[item.professionCateGory] = item.lengthSchooling;
                        let label = item.professionCateGoryName + '-' + item.professionCateGory;
                        ministryEduOption.push({
                            label: item.professionCateGory === '03003' ?  label: (item.ministryEduCode ? (item.professionCateGoryName + '-' + item.ministryEduCode) : item.professionCateGoryName),
                            value: item.professionCateGory
                        })
                        return {
                            label,
                            value: item.professionCateGory
                        }
                    })
                    this.ministryEduOption = ministryEduOption;
                    if(this.flag){
                        this.printForm.profession = '03003'
                    }
                    this.getShoolLength()
                }
            });
        },
        onSubmit() {
            if(this.queryForm.collegeReviewStartDate && this.queryForm.collegeReviewEndDate){
                let collegeReviewStartDate = forMateTimeToStr(this.queryForm.collegeReviewStartDate);
                let collegeReviewEndDate = forMateTimeToStr(this.queryForm.collegeReviewEndDate);
                if(collegeReviewStartDate > collegeReviewEndDate){
                    this.$message({
                                type: "warning",
                                message: "开始时间不能大于结束时间"
                            });
                    return;
                }
            }
            this.queryForm.pageNum_ = 1
            this.queryForm.pageSize_ = 20
            this.handleSearch();
        },
        reset(ref) {
            if(this.role == 4){
                this.queryForm.name = "";
                this.queryForm.pageNum_ = 1
                this.queryForm.pageSize_ = 20
                this.$refs[ref].resetFields();
                this.queryForm.lengthSchoolingList = []
            }else{
                this.queryForm.name = "";
                this.queryForm.pageNum_ = 1
                this.queryForm.pageSize_ = 20
                this.$refs[ref].resetFields();
                this.queryForm.faculty = this.options.faculty[0].value
                this.queryForm.lengthSchoolingList = []
            }
            let now = new Date();
            let currentYear = now.getFullYear()
            this.queryForm.graduationDate = `${currentYear}`;
            this.getReviewBatch();
            this.getMajorOptions();
            this.handleSearch();
        },
        exportPhone() {
            let params = this.getParams(this.queryForm)
            window.location.href = `/api/graduationservice/graduateList/exportPhotoGraphGraduateList?${params}`
        },
        getParams(data = {}) {
            let keys = Object.keys(data).filter(item=>item !== 'isOverseas'&& item !=='pageNum_' && item !=='pageSize_' && item !== 'total')
            let params = keys.reduce((prev, cur, index) => {
                prev += cur + '=' + data[cur];
                if (index < keys.length - 1) {
                    prev += '&';
                }
                return prev;
            }, '');
            return params;
        },
        btn6(){
            if(this.multipleSelection.length == 0){
                this.$message({
                    type: "warning",
                    message: "请先选择要退回审核结论的学生"
                });
                return;
            }
            let submit = this.multipleSelection.filter(d => d.submit != 1)
            if(submit.length > 0){
                this.$message({
                    type: "warning",
                    message: "仅可退回“已提交”状态的学院审核结论，请检查"
                });
                return;
            }
            let data = this.multipleSelection.map(d =>{
                return {
                    id:d.id,
                    studentId: d.studentId,
                    name: d.name,
                    collegeAuditConclusion: d.collegeAuditConclusion,
                };
            } )

            console.log(data)
            this.tableBtn6Data = data
            this.btn6Dialog = true;
            this.$nextTick(function () {
                this.tableBtn6Data.forEach(row => {
                    this.$refs.btn6table.toggleRowSelection(row,true);
                });
            });
        },
        btn6SelectionChange(selection){
            this.btn6Selection = selection;
        },
        resetbtn6(){
            this.tableBtn6Data = [];
            this.btn6Dialog = false;
        },
        cancelbtn6Dialog(){
            this.resetbtn6()
        },
        confirmbtn6Dialog(){
            if(this.btn6Selection.length == 0){
                this.$message({
                    type: "warning",
                    message: "请先选择要退回审核结论的学生"
                });
                return;
            }
            let data = {
                isOverseas: "1",
                ids: []
            }
            data.ids = _.map(this.btn6Selection, "id");
            saveReturnReviewConclusion(data).then(response => {
                if (response.code === 200) {
                    this.$message({
                        type: "success",
                        message: "设置成功"
                    });
                    this.btn6Dialog = false;
                    this.handleSearch();
                }
            });
        },
        setNumeber(name) {
            if(name == 'degree'){
                this.title = this.$t("graduationList.btn11")
            }
            if(name == 'minor'){
                this.title = this.$t("graduationList.btn10")
            }
            if(name == 'name'){
                this.title = this.$t("graduationList.resetGraduationList")
            }
            if(name == 'jiaowei'){
                this.title = this.$t("graduationList.btn3")
            }
            if(name == 'xuexin'){
                this.exportFileType = '2';
                this.title = this.$t("graduationList.btn2")
            }
            if(name == 'shangbao'){
                this.title = this.$t("graduationList.btn8")
            }
            if(name == 'OA'){
                this.title = this.$t("graduationList.btnOA")
            }
            if(name == 'report'){
                this.title = this.$t("graduationList.btnReport")
            }
            this.mode = name;
            this.showCourseDialog = true;
        },
        print(name){
            if(name == 'print'){
                this.title = this.$t("graduationList.btn12")
                let faculty = this.options.faculty.filter(data => data.value == '000182')
                if(faculty.length == 0){
                    this.mechineOptions.exportType = this.mechineOptions.exportType.filter(data => data.value == '2')
                }
            }
            if(name == 'xuewei'){
                this.printForm.faculty = '0'
                this.printForm.profession = '0'
                this.title = this.$t("graduationList.btn7")
            }
            if(name == 'fuxiu'){
                this.exportFileType = '1';
                this.title = this.$t("graduationList.btn9")
            }
            this.mode = name;
            this.showPrintDialog = true;
        },
        resetPrintValidate() {
            // 清除表单校验
            this.$refs.printForm.resetFields();
            this.title = "";
            this.mode = '';
            this.flag = false;
            this.mechineOptions.reviewBatch = []
        },
        printCancelDialog(){
            this.resetPrintValidate();
            this.showPrintDialog = false;
        },
        checkType(){
            if(this.printForm.printType == 2){
                this.flag = true;
                //this.printForm.faculty = '000182'
                //this.getMajorOptions2()
                this.getDialogFaculty();
            }else{
                this.flag = false;
                this.printForm.faculty = ''
                this.printForm.profession = ''
                this.printForm.graduationDate = ''
                this.printForm.reviewBatch = ''
                this.printForm.lengthSchooling = ''
                this.printForm.degreeType = ''
                this.mechineOptions.profession = [];
                this.ministryEduOption = [];
            }
        },
        checkWordType(){
            this.printForm.faculty = ''
            this.printForm.profession = ''
            this.printForm.graduationDate = ''
            this.printForm.reviewBatch = ''
            this.printForm.lengthSchooling = ''
            this.printForm.degreeType = ''
        },
        resetFormValidate() {
            // 清除表单校验
            this.$refs.mechineForm.resetFields();
            this.title = "";
            this.mode = '';
            this.mechineOptions.reviewBatch = []
            this.mechineOptions.profession = [];
            this.ministryEduOption = [];
            this.degreeType = ""
            this.collegeAuditConclusion = '0'
        },
        cancelDialog() {
            this.resetFormValidate();
            this.showCourseDialog = false;
        },
        confirmDialog() {
            this.$refs.mechineForm.validate(valid => {
                if (!valid) {
                    return;
                }
                let data = _.cloneDeep(this.mechineForm)
                if(data.reviewBatch == 6){
                    data.reviewBatch = ''
                }
                switch (this.title) {
                    case this.$t("graduationList.resetGraduationList"):
                        createGraduateList(this.mechineForm).then(response => {
                        if (response.code === 200) {
                                this.$message({
                                    type: "success",
                                    message: "初始化成功"
                                });
                                this.showCourseDialog = false;
                                this.handleSearch();
                            }
                        });
                        break;
                    case this.$t("graduationList.btn2"):
                        window.location.href =
                        '/api/graduationservice/graduateList/exportXueXinGraduateList?graduationDate='+this.mechineForm.graduationDate
                        +'&isOverseas=1'+'&reviewBatch='+data.reviewBatch+'&collegeAuditConclusion='+this.collegeAuditConclusion +'&exportFileType='+this.exportFileType
                        this.cancelDialog()
                        break;

                    case this.$t("graduationList.btn3"):
                        window.location.href =
                        '/api/graduationservice/graduateList/exportSecGraduateList?graduationDate='+this.mechineForm.graduationDate
                        +'&isOverseas=1'+'&reviewBatch='+data.reviewBatch+'&collegeAuditConclusion='+this.collegeAuditConclusion
                        this.cancelDialog()
                        break;

                    case this.$t("graduationList.btn8"):
                        window.location.href =
                        '/api/graduationservice/graduateList/exportDegreeReport?graduationDate='+this.mechineForm.graduationDate
                        +'&isOverseas=1'+'&reviewBatch='+data.reviewBatch+'&degreeType='+this.mechineForm.degreeType
                         this.cancelDialog()
                        break;

                    case this.$t("graduationList.btn10"):
                        editMinorCertificateNo(this.mechineForm).then(response => {
                            if (response.code === 200) {
                                this.$message({
                                    type: "success",
                                    message: "设置成功"
                                });
                                this.showCourseDialog = false;
                                this.handleSearch();
                            }
                        });
                        break;

                    case this.$t("graduationList.btn11"):
                        editCertificateNo(this.mechineForm).then(response => {
                            if (response.code === 200) {
                                this.$message({
                                    type: "success",
                                    message: "设置成功"
                                });
                                this.showCourseDialog = false;
                                this.handleSearch();
                            }
                        });
                        break;

                    case this.$t("graduationList.btnOA"):
                        window.location.href = `/api/graduationservice/graduateList/exportOAapply?graduationDate=${this.mechineForm.graduationDate}&reviewBatch=${data.reviewBatch}&isOverseas=1`;
                         this.cancelDialog()
                        break;

                    case this.$t("graduationList.btnReport"):
                        window.location.href = `/api/graduationservice/graduateList/exportDegreeReportFile?graduationDate=${this.mechineForm.graduationDate}&reviewBatch=${data.reviewBatch}&isOverseas=1`;
                         this.cancelDialog();
                        break;
                }

            });
        },
        printConfirmDialog(){
            this.$refs.printForm.validate(valid => {
                if (!valid) {
                    return;
                }
                let queryForm =_.cloneDeep(this.printForm);
                let data = _.cloneDeep(this.printForm)
                let queryParam = '';
                if(queryForm.reviewBatch == 6){
                    queryForm.reviewBatch = ''
                }
                if(data.reviewBatch == 6){
                    data.reviewBatch = ''
                }
                for (let key in queryForm) {
                    queryParam += `${key}=${queryForm[key]}&`;
                }
                switch (this.title) {
                    case this.$t("graduationList.btn7"):
                        data.faculty = data.faculty?data.faculty:0
                        data.profession = data.profession?data.profession:0
                        window.location.href =
                        '/api/graduationservice/graduateList/exportPrintDegreeCertificate?graduationDate='+data.graduationDate
                        +'&isOverseas=1'+'&faculty='+data.faculty+'&profession='+data.profession+'&reviewBatch='+data.reviewBatch
                        +'&degreeType='+data.degreeType
                        this.printCancelDialog()
                        break;

                    case this.$t("graduationList.btn9"):
                        this.printForm.fileType == 2 && (queryParam += `exportFileType=${this.exportFileType}`);
                        window.location.href =
                        '/api/graduationservice/graduateList/exportMinorDocuments?' + queryParam
                        this.printCancelDialog()
                        break;

                    case this.$t("graduationList.btn12"):
                        this.beforePrint(queryForm, queryParam);
                        this.printCancelDialog();
                        break;
                }
            });
        },
        async beforePrint(param, queryParam) {
            let isPDF = false
            if(param.printType == 3 || param.printType == 5){
                //证书发放名单、预计毕业全校统计
                isPDF = param.fileType==='1'? true : false
            }
            if (isPDF || param.printType === "0" || param.printType == 1 || param.printType == 2 || param.printType == 4) { // 1 2 4打印pdf
                let {data} = await printPdfInList(queryParam);
                let url = `/api/studentservice/assessApply/previewPersonTitle?objectKey=${data}`;
                window.open(url);
            }else {
                window.location.href = '/api/graduationservice/graduateList/exportExcel?' + queryParam;
            }
        },
        exportFile(name) {
            this.importUrl = '';
            this.mode = name;
            switch(name) {
                case 'EXL':
                    this.importUrl = '/api/graduationservice/graduateList/importCertificateNo';
                    this.uploadDialogTitle = this.$t('graduationList.btn4');
                    break;
                case 'EKS':
                    this.importUrl = '/api/graduationservice/graduateList/importExamNo';
                    this.uploadDialogTitle = this.$t('graduationList.importCandidateNumber');
            }
            this.$refs.uploadDialog.open();
        },
        uploadFile() {
			if (_.isEmpty(this.fileList)) {
				this.$message({
					type: "info",
					message: this.$t("message.selectFilePlease")
				});
				return;
			}
			this.$refs.upload.submit();
        },
        // 关闭弹出框
        clearFiles() {
            this.$refs.upload.clearFiles();
            this.fileList = [];
            this.mode = '';
            this.$refs.uploadDialog.close();
        },
        // 导入成功
        uploadDone(res) {
            if (res.code == 200) {
                this.$message({
                    type: 'success',
                    message: this.$t('common.tips.uploadSuccess')
                });
                this.handleSearch();
            }else{
                this.$message({
                    type: 'error',
                    message: res.msg
                });
                return 
            }
            this.clearFiles();
        },
        downloadFile(){
            let url = '/api/graduationservice/graduateList/exportCertificateNoTemplate';
            if (this.mode === 'EKS') {
                url = '/api/graduationservice/graduateList/downloadExamNoTemplate';
            }
            window.location.href = url;
        },
        exportTotalList() {
            let graduationDate = new Date().getFullYear();
            window.location.href = `/api/graduationservice/graduateList/exportAllList?graduationDate=${graduationDate}`;
        },
        handleStudent(mode, data) {
            let _this = this;
            const actions = {
                addRecord() {
                    if (!_this.queryForm.graduationDate) {
                        _this.$message({
                                type: "warning",
                                message: "请选择毕业年份"
                        });
                        return;
                    }
                    Object.assign(_this.studentDialog, {
                        add: {
                            show: true,
                        },
                        sendData: {
                            title: '新增毕业生',
                            isOverseas: '1',
                            graduationDate: _this.queryForm.graduationDate,
                            queryApi: manageApi.findStudentStatusInfo,
                            addApi: manageApi.addStudentInfo,
                            updateList: _this.handleSearch
                        }
                    })
                },
                deleteRecord() {
                    let msg = '确认删除吗?';
                    if (data.collegeAuditConclusion) {
                        msg = '该学生已有学院审核结论,确认是否删除?';
                    }
                    _this.$eduConfirm(msg, '删除').then((res) => {
                        manageApi.deleteStudentInfo({studentIds: data.studentId}).then(res =>{
                            _this.$message({
                                message: '删除学生成功',
                                type: 'success'
                            });
                            _this.handleSearch();
                        })
                    })
                },
                editRecord() {
                    let copyData = _.cloneDeep(data);
                    copyData.graduateTime && ( copyData.graduateTime += ' 00:00:00');
                    Object.assign(_this.studentDialog, {
                        edit: {
                            show: true,
                        },
                        sendData: {
                            title: '编辑',
                            data: copyData,
                            editApi: manageApi.editStudentInfo,
                            updateList: _this.handleSearch
                        }
                    })
                }
            }
            return actions[mode]();
        },
        cellClass ({row, column}){
            if (column.property != 'nameSpelling' && column.property != 'noPassCourse') {
                return 'preline'
            }
        }
    }
};
</script>
<style lang="scss" scoped>
    .div-main {
        margin-bottom: 16px;
    }
    .btn-right-list{
        .el-button+.el-button {
            margin-left: 5px;
        }
        .el-button--primary.el-button--small:not(.is-circle):not(.el-transfer__button) {
            padding: 0 8px;
        }
    }
    .collage-content ::v-deep .el-table{
        .cell, th div{
            padding-left: 3px;
            padding-right: 3px;
        }
    }
</style>

